home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / AppleScript / Switch Keyboard / ScreenMode ƒ / Read Me < prev   
Encoding:
Text File  |  1995-10-13  |  14.8 KB  |  140 lines  |  [ttro/ttxt]

  1. ScreenMode
  2.  
  3. ScreenMode is a utility that lets you change the resolution and bit depth of your display with a single mouse-click in just a second, without the usual trip to the Monitors control panel.
  4.  
  5. To achieve this is uses AppleScript. Why AppleScript ? Two reasons: first it uses an AppleScript Scripting Addition (or OSAX) which is part of a suite of Scripting Additions I am developing. I’m releasing this package based on it as I think it may be useful to people other than AppleScript programmers.
  6.  
  7. Second it is a very safe utility. It does not patch any traps or modify your system in any other way, so cannot interfere with other extensions or control panels you might have installed. In addition it does not effect performance or take up any memory until used.
  8.  
  9. Requirements
  10.  
  11. To benefit from ScreenMode you should be using a MultiScan monitor, i.e.. one that supports multiple resolutions, and a Mac that can drive such a display. This includes any PowerMac, 68040 Mac or PowerBook which can drive an external monitor, as well as some recent Macs with built in monitors.
  12.  
  13. ScreenMode requires AppleScript and the Display Manager software to run. AppleScript is Apple's system level scripting software. It was bundled with all PowerMacs, is now bundled with all Macs sold, and was included with System 7 Pro, System 7.5. It is also bundled with a number of applications, books and software collections.
  14.  
  15. According to Apple “The Display Manager is a set of system software functions that support dynamic changes to the arrangement and display modes of the displays attached to a user’s computer.” It is part of the system software of all PowerMacs, certain PowerBooks, and is a part of System 7.5.  It is also available (or was when I last checked) as an extension for other recent Macintosh models, in particular Quadra and LC models, at:
  16.  
  17. <ftp://sam.austin.apple.com/Apple.Support.Area/Apple.Software.Updates/US/Macintosh/Display_and_Peripheral/Display_Software_1.2.sea.hqx>
  18.  
  19. In short, if you have a PowerMac, or have System 7.5, then you have both AppleScript and the Display Manager. If you don’t have them probably the easiest way to get them is as part of System 7.5, though you can probably find them more cheaply online or bundled with third party software.
  20.  
  21. Installation
  22.  
  23. To install ScreenMode just drop the file "JWB Utilities" into your Scripting Additions folder, which is in  the Extensions folder inside your System Folder (if AppleScript is already installed). You don't need to restart. Once this is done ScreenMode is installed and ready to use.
  24.  
  25. Use
  26.  
  27. There are two sets of files included with ScreenMode which work in different ways to access its functionality. The perform exactly the same functions but work in slightly different ways.
  28.  
  29. Applets: These are miniature applications which when run change try and the screen resolution and depth of your display according to the values given in their names. For example running an applet “640 x 480, 8 bit” will  try and switch your monitor to 640 pixels wide by 480 pixels tall, i.e. 13" or VGA resolution, with 8-bit (256 colours) bit depth.
  30.  
  31. If it cannot do this, for example if your Macintosh or video card does not support this exact resolution, it will try and get as close as it can to the requested resolution and bit-depth specified. For example if the resolutions supported by your monitor are 640 x 480, 832 x 624 and 1024 x 768, and you run a “800 x 600, 16 bit” applet, your monitor should switch to 832 x 624, with a bit depth of as close as it can get to thousands of colours.
  32.  
  33. To use the applets just place them somewhere where they can conveniently be run when needed. You can put them in your Apple Menu, or in a folder in the Apple Menu, especially if you use Apple Menu Options or a similar hierarchical menu utility. You can install them in the Launcher, or just place them in the desktop. If you use Malph or a similar utility you can install aliases to them in it.
  34.  
  35. Scripts: Scripts are AppleScript programs. They are simpler and more compact than the applets, and so run more quickly. But they cannot run on their own, and require another program or utility able to run them. If possible you should use the scripts rather than the applets, simply because they execute a lot faster under most circumstances. They are also more likely to run when you are low on memory.
  36.  
  37. Many scriptable programs are now attachable, i.e. they allow you to add scripts to the program, typically by adding them to a menu. StuffIt Deluxe is one such program. Within these you can add scripts, including these scripts, so they can be run from within the program. Check your programs’ documentation for whether this is possible and how it is done.
  38.  
  39. There are also utilities that let you run scripts from within almost any application. Two that I know of are OSA menu and OtherMenu. OSA Menu is a freeware extension that places an iconic menu to the right of the menu bar and from which you can run, and allows you to run scripts from within any application.
  40.  
  41. OtherMenu is a ($10) shareware utility that places uses a similar universal menu at the right of the menu bar. The difference between it and OSA menu is that this menu is hierarchical and as well as scripts it can contain applications, files, folders, aliases and its own built-in commands. This is my own choice for running the scripts, which I have placed in a folder inside the OtherMenu folder for quick access.
  42.  
  43. Using ScreenMode with two or more devices connected
  44.  
  45. If you are have two or more devices connected to your Macintosh (e.g. two monitors, or a PowerBook’s screen together with an external monitor) then things are a lot more complicated.. For one thing here’s where the version of the Display Manager becomes important.
  46.  
  47. There are two major versions of the Display Manager. Version 1.0 is the original version, first bundled with the PowerMacs and now part of System 7.5. But there is a newer version, version 2.0, included in System 7.5.2 and all subsequent versions of the MacOS, i.e. bundled with all PCI PowerMacs and possibly other new Macs. Display Manager 2.0 is also available in an extension, Display Enabler, which judging from it’s version info may also be bundled with some Apple monitors, though where else you might get it I don’t know.
  48.  
  49. With Display Manager 1.0 and more than one display the resolution switching function of ScreenMode will not work. You can still switch the bit-depth using it, but you need version 2.0 or later of the Display Manager to make full use of ScreenMode if you have more that one display connected to your Mac.
  50.  
  51. With two or more displays attached you cannot specify which will be effected. Rather ScreenMode will search for a display on which is best able to match your request, starting with the main display, i.e. the one with the menu bar. This makes it more likely that it will satisfy your request exactly, and if it can’t do so makes it likely that it will come closer to matching your request than if you had only one display. 
  52.  
  53. This produces not entirely predictable results if you specify a mode supported by more than display. There is no easy way for me to add a way of specifying which display to ScreenMode, as the flexibility of the Mac’s display system places few limits on the number and arrangement of monitors connected to a Mac, meaning there is no simple and reliable way of specifying which one is which. But if anyone has any ideas about this, or a particular request which would be easy to deal with, let me know and I’ll see if I can incorporate it.
  54.  
  55. Other Notes
  56.  
  57. ScreenMode uses a similar mechanism to the Monitors control panel to change resolutions and bit-depths. This has some consequences you should be aware of:
  58.  
  59. ScreenMode does not stop you choosing a resolution which your display does not support. For example I have two VGA monitors which I use with my 6100/60AV. With either plugged into the AV card video port (with a suitable adapter - see <http://www.hk.super.net/~johnb/mtv.html> ) I can use ScreenMode or the Monitors control panel to drive the monitor at 1024 x 768 at 75Hz. But only one of my monitors supports this resolution, and the other will show garbage if I try this.
  60.  
  61. ScreenMode does try and protect you from this. If you choose a resolution that it considers “unsafe”, i.e. one that is on the list of optional resolutions for the video driver, it will throw up a dialog asking you to confirm. Because this dialog appears after you have switched resolutions you may not be able to see it, but the default in the dialog is “Cancel”, so if this happens just hit return and your display should be returned to it's initial state. This is not ideal as it depends on what your video driver or card considers “safe”, and the driver or card usually has no way of asking the monitor what resolutions it supports. Also this dialog can be disabled (see below).
  62.  
  63. Not all applications will recognise that the resolution has changed. Again you may be familiar with this if you use the Monitors control panel to switch resolutions while applications are running. The display manager tries telling all running programs of the changes it has made, but some programs take better note of this than others. You may have to move and zoom windows, close and reopen documents or even quit and restart the program to get things back to normal.
  64.  
  65. The changes made by ScreenMode are not permanent. By this I mean that any changes you make using ScreenMode will usually not be remembered by the system the next time you restart. you have to use the Monitors control panel to save the changes. This can be considered a feature, as it means that if you get into trouble using ScreenMode a restart will often cure you of the problem.
  66.  
  67. Adding support for other resolutions and depths
  68.  
  69. Because of the variety of bit-depths (six) and resolutions (ten ?) supported by Macintosh computers and displays, to cover all possible combinations of resolutions and bit-depths I would have to include over 100 scripts and applets in this package. This would involve a lot of needless repetition, as it is easy for you to add support for the resolution(s) and bit-depth(s) you desire.
  70.  
  71. To add support for a new resolution or bit depth do the following:
  72. Double-click on one of the existing scripts, which will open it with the Script Editor (installed as part of AppleScript)
  73. you should see single line of AppleScript, containing three numbers corresponding to the depth, width and height set by the script, e.g.
  74.  
  75. screenmode depth 16 width 1024 height 768 with confirmation
  76.  
  77. Change the numbers to those you desire, e.g.
  78.  
  79. screenmode depth 32 width 1024 height 768 with confirmation
  80.  
  81. Then Use “Save As...” to save your changes, choosing whether it will be an Application (applet) or Compiled Script (script) from the pop-up menu..(if you use “Save” rather than “Save As...” it will overwrite the script you started with).
  82.  
  83. Disabling of the confirmation dialog
  84.  
  85. To get rid of the confirmation dialog that appears when you run a script or applet specifying an “unsafe” mode repeat the above steps, but instead of changing any numbers just delete the words “with confirmation” from the end of the line you see, then use “Save” or “Save As...” to save the resulting script.
  86.  
  87. JWB Utilities and scripting notes.
  88.  
  89. JWB Utilities (version 1.1) is an OSAX suite containing two AppleScript commands, as follows (quoting from the OSAX dictionary):
  90.  
  91. switch keyboard: Switch to next keyboard within current script
  92.     switch keyboard
  93.  
  94.  - this command changes the active keyboard to the next one in the current script (e.g. Roman, Kanji, ...), going by the order in the Keyboard control panel. It is equivalent to pressing Command-Option-space. It’s a one-trick wonder which was coded in an hour after someone on the Mac Scripting mailing list asked for it and because I wanted to try my hand at a simple OSAX.
  95.  
  96. screenmode: configures a monitor to best match given parameters
  97.     screenmode
  98.         depth  integer  -- bit depth (one of 1,2,4,8,16 or 32)
  99.         width  integer  -- screen width in pixels
  100.         height  integer  -- screen height in pixels
  101.         [confirmation  boolean]  -- confirm mode change ? (default no)
  102.  
  103.  - this is what this package is about. This documentation and example scripts, together with the above dictionary, should tell you all you need to be able to use this in your own scripts.
  104.  
  105. One thing that’s perhaps not obvious is the optional confirmation flag. This defaults to off if this parameter is omitted, as if you are using this in a script you probably don‘t want it throwing up dialogs mid way through a script. Confirmation is turned on in all included scripts and applets, as if you have something lying around on your disk that can change resolution with a single mouse-click you probably want a chance to confirm any unsafe changes made by it, at least until you’re sure it works with your Mac.
  106.  
  107. Version History for JWB Utilities
  108.  
  109. 1.0 - 14 August 1995 - first version with only the switch keyboard command, limited release
  110. 1.1 - 12 October 1995 - added screenmode, renamed to JWB Utilities
  111.  
  112. Legalese
  113.  
  114. ScreenMode, consisting of this documentation, JWB Utilities and sample scripts and applets, is © 1995 John W. Blackburne. It is being distributed as freeware, and may be freely copied for personal, educational or professional use on Macintosh computers. It may be freely uploaded to any BBS, ftp site or online service, provided no charge is associated with its download above normal online charges for that service and provided it is uploaded as a complete package.
  115.  
  116. It may not be included as part of any other software package, or any software collection, without my prior explicit approval (which is usually easily obtained for any reasonable purpose). It may be included on CD-ROM compilations of software, provided I receive a copy of the final product, or am at least offered the final product at a very favourable discount, and it is included as a complete package. It may not be sold, or included with any product for sale, in any other circumstances.
  117.  
  118. Other stuff
  119.  
  120. Although this is free, if you like this so much you want to send me something I’m not going to refuse. Easiest is to just e-mail me a message. If you want to drop me a postcard that's fine, especially if you come from strange foreign parts, like North America or Europe. If you want to send me software, or any other cool stuff, that’s fine too.
  121.  
  122. Other Mac software I’ve released includes ExcelTalk (a utility to make Excel talk) and Tempest Chess (a chess game for FirstClass BBSes). Have a look at my Web pages at <http://www.hk.super.net/~johnb/> for information on them and what else I've done and am up to. You can also find most of what I've done on Tempest, the FirstClass BBS I run, which can be reached on Hong Kong (+852) 2816 7734.
  123.  
  124. Thanks to
  125.  
  126. Gregory Rivers for his valuable advice
  127. Donald Olson and Eric Anderson for sample code
  128. MetroWerks for the cool tools
  129. & of course Apple for such cool technology
  130.  
  131. Contact details
  132.  
  133. John W. Blackburne
  134. Flat 6, 21st floor,
  135. 102 - 114 Belcher’s Street
  136. Hong Kong
  137.  
  138. Tel: Hong Kong (+852) 2816 7484
  139. Internet: johnb@tempest.net.hk
  140. eWorld: JWB